package cn.buk.tms.dto;

import cn.buk.tms.entity.misc.CustomerDepartment;
import cn.buk.tms.common.dto.CustomerDto;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author yfdai
 */
public class CustomerDepartmentDto {

  private int id;

  /**
   * 客户id
   */
  private Integer customerId;

  /**
   * 客户名称
   */
  private String customerName;

  private CustomerDto customer;

  /**
   * 部门ID
   */
  private Integer departmentNo;

  /**
   * 部门名称
   */
  private String name;

  /**
   * 上级部门ID
   */
  private Integer parentDepartmentNo;

  /**
   * 上级部门名称
   */
  private String parentDepartmentName;

  /**
   * 部门层级
   */
  private int level;

  /**
   * 部门联系人
   */
  private String linkman;

  private String mobile;

  private String phone;

  private String email;

  private String remark;


  private Date createTime;

  /**
   * 审批人列表
   */
  private List<CustomerTravelApproverDto> approvers;

  private Date lastUpdate;

  public static CustomerDepartmentDto createBy(CustomerDepartment o) {
    if (o == null) return null;

    CustomerDepartmentDto dto = new CustomerDepartmentDto();
    BeanUtils.copyProperties(o, dto, "customer");

    if (o.getCustomer() != null) {
      dto.setCustomer(CustomerDto.create(o.getCustomer().getId(), o.getCustomer().getVipName(), o.getCustomer().getCustomerCode()));
    }

    return dto;
  }

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public Integer getDepartmentNo() {
    return departmentNo;
  }

  public void setDepartmentNo(Integer departmentNo) {
    this.departmentNo = departmentNo;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public Integer getParentDepartmentNo() {
    return parentDepartmentNo;
  }

  public void setParentDepartmentNo(Integer parentDepartmentNo) {
    this.parentDepartmentNo = parentDepartmentNo;
  }

  public int getLevel() {
    return level;
  }

  public void setLevel(int level) {
    this.level = level;
  }

  public String getLinkman() {
    return linkman;
  }

  public void setLinkman(String linkman) {
    this.linkman = linkman;
  }

  public String getMobile() {
    return mobile;
  }

  public void setMobile(String mobile) {
    this.mobile = mobile;
  }

  public String getPhone() {
    return phone;
  }

  public void setPhone(String phone) {
    this.phone = phone;
  }

  public String getEmail() {
    return email;
  }

  public void setEmail(String email) {
    this.email = email;
  }

  public String getRemark() {
    return remark;
  }

  public void setRemark(String remark) {
    this.remark = remark;
  }

  public Date getCreateTime() {
    return createTime;
  }

  public void setCreateTime(Date createTime) {
    this.createTime = createTime;
  }

  public Date getLastUpdate() {
    return lastUpdate;
  }

  public void setLastUpdate(Date lastUpdate) {
    this.lastUpdate = lastUpdate;
  }

  public String getParentDepartmentName() {
    return parentDepartmentName;
  }

  public void setParentDepartmentName(String parentDepartmentName) {
    this.parentDepartmentName = parentDepartmentName;
  }

  public Integer getCustomerId() {
    return customerId;
  }

  public void setCustomerId(Integer customerId) {
    this.customerId = customerId;
  }

  public String getCustomerName() {
    return customerName;
  }

  public void setCustomerName(String customerName) {
    this.customerName = customerName;
  }

  public List<CustomerTravelApproverDto> getApprovers() {
    if (approvers == null) {
      approvers = new ArrayList<>();
    }
    return approvers;
  }

  public void setApprovers(List<CustomerTravelApproverDto> approvers) {
    this.approvers = approvers;
  }

  public CustomerDto getCustomer() {
    return customer;
  }

  public void setCustomer(CustomerDto customer) {
    this.customer = customer;
  }
}
